<%-- 
    Document   : events
    Created on : Jul 13, 2013, 6:55:11 PM
    Author     : Logic
--%>

<%@page import="info.toegepaste.www.beans.Alumnus"%>
<%@page import="info.toegepaste.www.beans.Account"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="info.toegepaste.www.beans.Event"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Eventpagina</title>
        <link rel="stylesheet" type="text/css" href="style.css"/>
    </head>
    <body>
        <%

            ArrayList<Integer> IDs = new ArrayList<Integer>();
            if (request.getAttribute("IDs") != null) {
                IDs = (ArrayList<Integer>) request.getAttribute("IDs");
            }
        %>
        <a href="index.jsp"><h1>Alumni</h1></a>
        <label><%if (session.getAttribute("alumnus") != null) {
                Account login = (Account) session.getAttribute("login");
                Alumnus alumnus = (Alumnus) session.getAttribute("alumnus");
            %>

            <p>Welkom <%
                if (login.getType().equals("a")) {%>
                <%=alumnus.getVoornaam()%> <%=alumnus.getAchternaam()%>
                <%} else if (login.getType().equals("m")) {%>
                Administrator
                <%}%></p>


        </label>
        <%}%>
        <form action="RegistratieServlet" method="POST">
            <input class="knop" type="submit" value="Uitloggen" name="logoutButton"/>
        </form>
        <h2>Events</h2>
        <%ArrayList<Event> events = (ArrayList<Event>) request.getAttribute("events");
            SimpleDateFormat formatter = new SimpleDateFormat(
                    "dd/MM/yyyy ");%>
        <table style="border: 1px solid white;">
            <thead>
            <th>Nummer</th>
            <th>Naam</th>
            <th>Beschrijving</th>
            <th>Plaats</th>
            <th>Datum</th>
        </thead>
        <tbody>
            <%for (Event event : events) {%>
            <tr>
                <td><%=event.getEventID()%></td>
                <td><%=event.getEventnaam()%></td>
                <td><%=event.getEventBeschrijving()%></td>
                <td><%=event.getPlaats()%></td>
                <td><%=formatter.format(event.getDatumEvent())%></td>
                <%if (session.getAttribute("alumnus") != null) {%>
                <td>
                    <form action="RegistratieServlet" method="get">
                        <%if (IDs.contains(event.getEventID())) {%>
                        <p>Ingeschreven</p>
                        <%} else {%>
                        <input type="submit" value="Inschrijven" name="inschrijven<%=event.getEventID()%>"/>
                        <%}%>
                    </form>
                </td>
                <td><form action="RegistratieServlet" method="get"><input type="submit" value="Ingeschreven" name="ingeschreven<%=event.getEventID()%>"/></form></td>
                        <%}%>
            </tr>

            <%}%>
        </tbody>


    </table>
        <form action="AdminServlet" method="post">
            <input type="submit" name="eventtoevoegen" value="Event toevoegen">
        </form>
</body>
</html>
